<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [1, 3, 5, 8, 5, 3, 10, 10, 1, 2, 4]
        let obj = {}
        arr.forEach(item => {
            if (obj[item]) {
                obj[item]++
            } else {
                obj[item] = 1
            }
        })

        for (const key in obj) {
            console.log(`${key}出现了${obj[key]}次`)
        }
    </script>
</body>

</html>